#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>
#include <Measure.h>
#include <Unit.h>
#include <string>
#include <sstream>
#include <UnitFormat.h>

USING_MOCKCPP_NS USING_TESTNGPP_NS

FIXTURE(Length)
{
    TEST(1 MILE ==1760 YARD should be true)
    {
        LENGTH length1(1, MILE), length2(1760, YARD);
        ASSERT_TRUE(length1==length2);
    }

    TEST(3 YARD ==3 YARD should be true)
    {
        LENGTH length1(3, YARD), length2(3, YARD);
        ASSERT_TRUE(length1==length2);
    }

    TEST(2 MILE !=1760 YARD should be true)
    {
        LENGTH length1(2, MILE), length2(1760, YARD);
        ASSERT_TRUE(length1!=length2);
    }

    TEST(4 YARD !=3 YARD should be true)
    {
        LENGTH length1(4, YARD), length2(3, YARD);
        ASSERT_TRUE(length1!=length2);
    }

    TEST(1 YARD ==3 FEET should be true)
    {
        LENGTH length1(1, YARD), length2(3, FEET);
        ASSERT_TRUE(length1==length2);
    }
    TEST(1 MILE ==3*1760 FEET should be true)
    {
        LENGTH length1(1, MILE), length2(5280, FEET);
        ASSERT_TRUE(length1==length2);
    }
    TEST(1 YARD+ 2 FEET = 5 FEET)
    {
        LENGTH totalLength(5,FEET), length1(1, YARD), length2(2, FEET);
        ASSERT_TRUE(totalLength==length1+length2);
    }
};

FIXTURE(Length_output_by_unit_seq)
{
    TEST(1770 YARD output should be "1 MILE 10 YARD")
    {
        std::ostringstream out;

        LENGTH length(1770,YARD);
        length.output(out, LENGTH_OUTPUT_BY_SEQ);
        ASSERT_EQ("1 MILE 10 YARD", out.str());
    }

    TEST(0 MILE output should be "0 FEET")
    {
        std::ostringstream out;
        LENGTH length(0,MILE);
        length.output(out, LENGTH_OUTPUT_BY_MINUNIT);
        ASSERT_EQ("0 FEET", out.str());
    }
};

FIXTURE(Length_output_by_min_unit)
{
    TEST(1770 YARD output should be "5310 FEET")
    {
        std::ostringstream out;
        LENGTH length(1770,YARD);
        length.output(out, LENGTH_OUTPUT_BY_MINUNIT);
        ASSERT_EQ("5310 FEET", out.str());
    }

    TEST(0 MILE output should be "0 FEET")
    {
        std::ostringstream out;
        LENGTH length(0,MILE);
        length.output(out, LENGTH_OUTPUT_BY_SEQ);
        ASSERT_EQ("0 FEET", out.str());
    }
};
